home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / maximus / mul100.zip / VIEW.SCR < prev   
Text File  |  1993-02-01  |  12KB  |  320 lines

  1.  
  2. // VIEW.SCR  --  MUL/UV Maximus User Language - User View  --  Version 1.00
  3. //
  4. // Script program for MUL - the Maximus User Language
  5. // MUL is (C) Copyright 1990-93 by CodeLand Australia
  6.  
  7. char *ufile = "USER.BBS";                   // Path & name of Maximus user file
  8. //char *ufile = "C:\\BBS\\USER.BBS";        // Path & name of Maximus user file
  9.  
  10. int backch=0xB0;                            // Background fill character
  11. int bdr = 0;                                // Window border type
  12. int battr = Attr (WHITE,GREEN);             // Colour - window border
  13. int wattr = Attr (BLACK,GREEN);             // Colour - window body
  14. int qattr = Attr (YELLOW,GREEN);            // Colour - windows headings
  15. int fattr = Attr (LGREY,BLACK);             // Colour - window fields
  16. int hattr = Attr (LRED,BLACK);              // Colour - highlight fields
  17. int mattr = Attr (YELLOW,GREEN);            // Colour - menu
  18.  
  19. int current_record=1;                       // Current record
  20. char buf[40];                               // Search buffer
  21. int search_stop=0;                          // Search work variable
  22.  
  23. main ()                                     // Main program
  24. {
  25.     if (!BaseOpenR (ufile)) {
  26.         printf ("\nERROR opening user file \"%s\"\n\n",ufile);
  27.         exit ();
  28.     }
  29.  
  30.     background ();                          // Display background
  31.     view ();                                // Display the records
  32.  
  33.     Wclose ();                              // Close background
  34.     BaseClose ();                           // Close the user base
  35. }
  36.  
  37. background ()                               // Display background
  38. {
  39.     Wfillch (backch);
  40.     Wopen (0,0,NumRows ()-1,NumCols ()-1,5,0,Attr (YELLOW,LGREY));
  41.     Wfillch (0x20);
  42. }
  43.  
  44. view ()                                     // Display the records
  45. {
  46.     int key, done=0;
  47.  
  48.     // Open the screen window
  49.     if (!Wopen (1,4,23,74,bdr,battr,wattr)) return;
  50.  
  51.     Wshadow (Attr (LGREY,BLACK));
  52.     Hidecur ();                             // Hide the cursor
  53.     write_labels ();                        // Write the static screen data
  54.  
  55.     if (!BaseRead (current_record)) {       // Read first record
  56.         Wclose ();                          // Close the screen window
  57.         return;
  58.     }
  59.  
  60.     write_display ();                       // Display first record to screen
  61.  
  62.     while (!done) {
  63.         key=getxch ();              // Get keyboard character code
  64.  
  65.         while(key) {                // Allow screen write skip
  66.             // Right arrow, Grey plus, Dn arrow
  67.             if ( key==0x4D00 || key==0x4E2B || key==0x5000) {
  68.                 if (current_record<BaseCount ()) ++current_record;
  69.             }
  70.             // Left arrow, Grey minus, Up arrow
  71.             else if ( key==0x4B00 || key==0x4A2D || key==0x4800) {
  72.                 if (current_record>1) --current_record;
  73.             }
  74.             // ESC, q, Q
  75.             else if ( key==0x011B || key==0x1071 || key==0x1051) {
  76.                 ++done; break;
  77.             }
  78.             // Home
  79.             else if ( key==0x4700) {
  80.                     current_record=1;
  81.             }
  82.             // End
  83.             else if ( key==0x4F00) {
  84.                     current_record=BaseCount ();
  85.             }
  86.             // PgDn
  87.             else if ( key==0x5100) {
  88.                     current_record=current_record+15;
  89.                     if (current_record>BaseCount ())
  90.                         current_record=BaseCount ();
  91.             }
  92.             // PgUp
  93.             else if ( key==0x4900) {
  94.                     current_record=current_record-15;
  95.                     if (current_record<1)
  96.                         current_record=1;
  97.             }
  98.             // s, S
  99.             else if ( key==0x1F73 || key==0x1F53) {
  100.                 current_record=search ();
  101.             }
  102.             // a, A
  103.             else if ( key==0x1E61 || key==0x1E41) {
  104.                 About (6); getxch (); Wclose ();
  105.             }
  106.  
  107.             if (kbhit()) key=getxch ();     // Get keyboard character code
  108.             else key=0;
  109.         }
  110.  
  111.         // Update the display
  112.         BaseRead (current_record);
  113.         write_display ();
  114.     }
  115.  
  116.     Wclose ();                              // Close the screen window
  117. }
  118.  
  119. write_labels ()                             // Write the static screen data
  120. {
  121.     Wxyputs (0, 1,qattr,"Flags");
  122.     Wxyputs (0, 8,fattr,"         ");    Wxyputs (0,19,fattr,"       ");
  123.     Wxyputs (0,28,qattr,"Index");        Wxyputs (0,34,hattr,"File Order ");
  124.     Wxyputs (0,47,qattr,"Record       of");
  125.     Wxyprintf (0,63,hattr,"%5u",BaseCount ());
  126.  
  127.     Whline (1,0,69,bdr,battr);           Whline(8,0,69,bdr,battr);
  128.     Wvline( 8,57,11,bdr,battr);          Whline(19,0,69,bdr,battr);
  129.  
  130.     Wxyputs ( 2, 1,wattr,"Name :");      Wxyputs ( 2,44,wattr,"PassWord:");
  131.     Wxyputs ( 7, 1,wattr,"Alias:");      Wxyputs ( 4,34,wattr,"Nerd:");
  132.     Wxyputs ( 5, 1,wattr,"City :");      Wxyputs ( 5,48,wattr,"Phone:");
  133.     Wxyputs ( 7,28,wattr,"LCall:");      Wxyputs ( 7,52,wattr,"Access:");
  134.     Wxyputs ( 9, 1,wattr,"Calls:");      Wxyputs ( 9,14,wattr,"Credit:");
  135.     Wxyputs ( 9,29,wattr,"Debit:");      Wxyputs ( 9,43,wattr,"Lang:");
  136.     Wxyputs (11, 1,wattr,"Msg. Area:");  Wxyputs (11,22,wattr,"Dnlds Today:");
  137.     Wxyputs (11,42,wattr,"TimeToday:");  Wxyputs (12, 1,wattr,"File Area:");
  138.     Wxyputs (12,22,wattr,"Total Dnlds:");Wxyputs (12,42,wattr,"Scrn Wdth:");
  139.     Wxyputs (13, 1,wattr,"File Tran:");  Wxyputs (13,22,wattr,"Total Uplds:");
  140.     Wxyputs (13,42,wattr,"Scrn Lgth:");  Wxyputs (14, 1,wattr,"File Comp:");
  141.     Wxyputs (14,42,wattr,"Nulls    :");  Wxyputs (15,22,wattr,"Action:");
  142.     Wxyputs (16,22,wattr,"Demote:");     Wxyputs ( 9,59,wattr,"MaxEd:");
  143.     Wxyputs (10,59,wattr,"FScnR:");      Wxyputs (11,59,wattr,"Hot K:");
  144.     Wxyputs (12,59,wattr,"IBMch:");      Wxyputs (13,59,wattr,"More :");
  145.     Wxyputs (14,59,wattr,"Cls:  ");      Wxyputs (15,59,wattr,"Ulstd:");
  146.     Wxyputs (16,59,wattr,"ChAvl:");      Wxyputs (17,59,wattr,"UsdMx:");
  147.     Wxyputs (18,59,wattr,"BadLg:");      Wxyputs (16, 1,wattr,"EXpiry:");
  148.     Wxyputs (18,19,wattr,"Keys:");
  149.     Wxyputs (17,24,wattr,"┌──────┐┌──────┐┌──────┐┌──────┐");
  150.  
  151.     Wxyputs (20,1,battr,"MUL/UV - Maximus User Language - User View v1.00");
  152.     Wxyputs (20,56,battr,"S");           Wxyputs (20,57,mattr,"EARCH");
  153.     Wxyputs (20,64,battr,"Q");           Wxyputs (20,65,mattr,"UIT");
  154. }
  155.  
  156. write_display ()                            // Display record to screen
  157. {
  158.     if (USRflagperm) Wxyputs (0, 8,hattr,"PERMANENT");
  159.     else             Wxyputs (0, 8,hattr,"         ");
  160.     if (USRflagdel)  Wxyputs (0,19,hattr,"DELETED");
  161.     else             Wxyputs (0,19,hattr,"       ");
  162.  
  163.     Wxyprintf (0,54,hattr,"%5u",current_record);
  164.  
  165.     Wxyprintf (2, 7,fattr,"%-35s",USRname);
  166.     Wxyprintf (2,53,fattr,"%-15s",USRpwd);
  167.     Wxyprintf (7, 7,fattr,"%-20s",USRalias);
  168.     Wxyprintf (5, 7,fattr,"%-35s",USRcity);
  169.     if (USRextra) Wxyputs (5,43,hattr,"EXT");
  170.     else          Wxyputs (5,43,hattr,"   ");
  171.     Wxyprintf (5,54,fattr,"%-14s",USRphone);
  172.     Wxyputs (7,34,fattr,DateToStr (USRludate));
  173.     Wxyputs (7,43,fattr,TimeToStr (USRlutime));
  174.     Wxyputs (7,59,fattr,BasePrivStr (USRpriv));
  175.  
  176.     Wxyprintf (9,7,fattr,"%5u",USRcalls);
  177.     Wxyprintf (9,21,fattr,"%6u",USRcredit);
  178.     Wxyprintf (9,35,fattr,"%6u",USRdebit);
  179.     Wxyprintf (9,48,fattr,"%8d",USRlang);
  180.     Wxyprintf (11,11,fattr,"%-9s",USRmsg);
  181.     Wxyprintf (11,34,fattr,"%6lu",USRdnldtoday);
  182.     Wxyprintf (11,52,fattr,"%4u",USRtimetoday);
  183.     Wxyprintf (12,11,fattr,"%-9s",USRfiles);
  184.     Wxyprintf (12,34,fattr,"%6lu",USRdnld);
  185.     Wxyprintf (12,52,fattr,"%4u",USRwidth);
  186.     Wxyputs (13,11,fattr,BaseProtStr (USRdefprot));
  187.     Wxyprintf (13,34,fattr,"%6lu",USRupld);
  188.     Wxyprintf (13,52,fattr,"%4u",USRlen);
  189.     Wxyprintf (14,11,fattr,"%9u",USRcompress);
  190.     Wxyprintf (14,52,fattr,"%4u",USRnulls);
  191.  
  192.     // User flags
  193.     Wxyputs ( 4,39,fattr,YesNo (USRflagnerd));
  194.     Wxyputs ( 9,65,fattr,YesNo (!USRflagbored));
  195.     Wxyputs (10,65,fattr,YesNo (USRflagfsr));
  196.     Wxyputs (11,65,fattr,YesNo (USRflaghotkeys));
  197.     Wxyputs (12,65,fattr,YesNo (USRflagibmchars));
  198.     Wxyputs (13,65,fattr,YesNo (USRflagmore));
  199.     Wxyputs (14,65,fattr,YesNo (USRflagcls));
  200.     Wxyputs (15,65,fattr,YesNo (!USRflagnoulist));
  201.     Wxyputs (16,65,fattr,YesNo (!USRflagnotavail));
  202.     Wxyputs (17,65,fattr,YesNo (USRflagusedmax));
  203.     Wxyputs (18,65,fattr,YesNo (USRflagbadlogon));
  204.  
  205.     Wxyputs (18, 1,fattr,BaseVideoStr (USRvideo));
  206.     Wxyputs (18,10,fattr,BaseHelpStr (USRhelp));
  207.     Wxyputs (18,24,fattr,BaseKeyStr (USRkeys,1));
  208.  
  209.     // Expiry
  210.     if(And (USRxpflag,XP_DATE) || And (USRxpflag,XP_TIME)) {
  211.         if(And (USRxpflag,XP_HANGUP)) {
  212.             Wxyputs (15,29,fattr,"HangUp   ");
  213.             Wxyputs (16,29,fattr,"         ");
  214.         }
  215.         else if(And (USRxpflag,XP_DEMOTE)) {
  216.             Wxyputs (15,29,fattr,"Demote   ");
  217.             Wxyputs (16,29,fattr,BasePrivStr (USRxppriv));
  218.         }
  219.         else {
  220.             Wxyputs (15,29,fattr,"None     ");
  221.             Wxyputs (16,29,fattr,"         ");
  222.         }
  223.  
  224.         if(And (USRxpflag,XP_DATE)) {
  225.             Wxyputs (16, 8,fattr,"Date");
  226.             Wxyputs (16,13,fattr,DateToStr (USRxpdate));
  227.         }
  228.         else if(And (USRxpflag,XP_TIME)) {
  229.             Wxyputs (16, 8,fattr,"Time");
  230.             Wxyprintf (16,13,fattr,"%8lu",USRxpmins);
  231.         }
  232.     }
  233.     else {
  234.         Wxyputs (15,29,fattr,"         ");
  235.         Wxyputs (16,29,fattr,"         ");
  236.         Wxyputs (16, 8,fattr,"None");
  237.         Wxyputs (16,13,fattr,"        ");
  238.     }
  239. }
  240.  
  241. search ()                                   // Search for user name
  242. {
  243.     int i, found=0, colr=Attr (WHITE,RED);
  244.  
  245.     // Open the search window
  246.     if (!Wopen (16,21,20,59,bdr,colr,Attr (LGREY,RED))) return;
  247.  
  248.     Wshadow (Attr (LGREY,BLACK));
  249.     Wxyputs (0, 1,colr,"Search Name:");
  250.  
  251.     if (search_stop) { // If an auto find next
  252.  
  253.         Wxyputs (0,22,Attr (YELLOW,LRED),"Searching");
  254.         Wxyputs (2, 1,Attr (LGREY,BLACK),"                                   ");
  255.         Wxyputs (2, 1,Attr (LGREY,BLACK),buf);
  256.  
  257.         // Search loop
  258.         for (i=search_stop;i<=BaseCount ();++i) {
  259.  
  260.             // Check for keyboard abort (SPACE)
  261.             if (kbhit ()) if (getch ()==' ') { search_stop=0; break; }
  262.  
  263.             if (!(i%20))Wxyprintf (0,32,Attr (YELLOW,RED),"%4u",i);
  264.  
  265.             BaseRead (i);                   // Read the record
  266.             if (strisocc (buf,USRname)) {   // If a match found
  267.                 ++found;
  268.                 current_record=i;
  269.                 break;
  270.             }
  271.          }
  272.  
  273.         if (found) {
  274.             Play (536,60);
  275.             search_stop=i+1;
  276.             if (search_stop>BaseCount ()) search_stop=0;
  277.         }
  278.         else { Play (268,500); search_stop=0; }
  279.     }
  280.     else { // Do normal search
  281.         Wxyputs (2, 1,Attr (LGREY,BLACK),"                                   ");
  282.         Wgotoxy (2,1);
  283.         Showcur ();
  284.         if(!getns (buf,35)) {
  285.             Hidecur ();
  286.             if (buf[0]) { // If we have a search string
  287.                 Wxyputs (0,22,Attr (YELLOW,LRED),"Searching");
  288.  
  289.                 // Search loop
  290.                 for (i=1;i<=BaseCount ();++i) {
  291.  
  292.                     // Check for keyboard abort (SPACE)
  293.                     if (kbhit ()) if (getch ()==' ') break;
  294.  
  295.                     if (!(i%20))Wxyprintf (0,32,Attr (YELLOW,RED),"%4u",i);
  296.  
  297.                     BaseRead (i);               // Read the record
  298.                     if (strisocc (buf,USRname)) {
  299.                         ++found;
  300.                         current_record=i;
  301.                         break;
  302.                     }
  303.                 }
  304.  
  305.                 if (found) {
  306.                     Play (536,60); search_stop=i+1;
  307.                     if (search_stop>BaseCount ()) search_stop=0;
  308.                 }
  309.                 else { Play (268,500); search_stop=0; }
  310.             }
  311.         }
  312.     }
  313.  
  314.     Hidecur (); Wclose ();                  // Hide cursor, close window
  315.     return current_record;
  316. }
  317.  
  318. // End of script
  319.  
  320.